package control
{
	import model.ModelLocator;
	import flash.net.URLVariables;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;
	import mx.controls.Alert;
	public class SendMessage
	{
		internal var theModel:ModelLocator = ModelLocator.getInstance();
		 private var SendMessageHttp:HTTPService;
		public function SendMessage()
		{
			SendMessageHttp = new HTTPService();
			SendMessageHttp.url = "http://localhost:8080/" + ModelLocator.WEB + "/servlet/SendMessage";
			SendMessageHttp.addEventListener(ResultEvent.RESULT,SendMessageResultHandler);
		}
		
		public function doSendMessage(content:String,markerid:String,username:String):void{
			var params:URLVariables = new URLVariables();
			params.content = content;
			params.markerid = markerid;
			params.username = username;
			SendMessageHttp.send(params);
		}
		
		public function SendMessageResultHandler(e:ResultEvent){
			if(e.result.Result.STATUS == "Successful"){
				Alert.show("send message successful");
			}else{
				Alert.show("A bug~~,Please commit it again.");
			}
		}

	}
}